import Vue from 'vue'
import Router from 'vue-router'
import login from './views/login/index.vue'
import index from './views/admin/default.vue'
import coursebyid from "./views/course/coursebyid.vue"
import watchuser from "./views/user/watchuser.vue"
import packageCourse from "./views/packages/packageCourse.vue"
import oss from "./views/oss/index.vue"
import lesson from "./views/lesson/lesson.vue"
import videos1 from './views/video/index.vue'
import ifreams from "./views/ifream/createifream.vue"
import catebagbyid from "./views/packages/catebagbyid.vue"
import watchkecb from "./views/packages/watchkecb.vue"
import watchcatebagtype from "./views/packages/watchcatebagtype.vue"
import fileurl from './views/course/fileurl.vue'
import wechattemp from './views/wechat/temp.vue'
import wechat from './views/wechat/index.vue'
import wechatpushs from './views/wechat/pushs.vue'
import wechatfans from './views/wechat/fans.vue'
import secretfile from './views/secretfile/index.vue'
import teacherdata from './views/teacher/index.vue'
import watchteacherproposal from './views/teacher/watchteacherproposal.vue'
import itembankgroup from './views/itembank/group.vue'
import answer from './views/itembank/answer.vue'
import watchitembankgroup from './views/itembank/watchitembankgroup.vue'
import Serialgroup from "./views/Serialgroup/index.vue"
import packageCourse1 from "./views/Generateserial/packageCourse1.vue"
import packageCourse2 from "./views/Generateserial/packageCourse2.vue"
import coderobot from './views/product/coderobot.vue'
import library from './views/product/library.vue'
import School from './views/school/index.vue'
import school_list from './views/school/list.vue'
// 
import school_groupdetail from './views/school/school_groupdetail.vue'

import school_watchschool from './views/school/watchschool.vue'
import newspackage from './views/Generateserial/newspackage.vue'
import userCourse from './views/user/userCourse.vue'
import userUser from './views/user/userUser.vue'
import teacherCourse from './views/user/teacherCourse.vue'
import userPackage from './views/user/userPackage.vue'
Vue.use(Router)

import {
  get
} from "axios"
export default new Router({
  routes: [{
    path: '/',
    name: 'home',
    redirect: "/login",
  },
  {
    path: '/admin',
    name: 'admin',
    component: () => import( /* webpackChunkName: "about" */ './views/admin/index.vue'),
    children: [
      {
        path: '/index',
        name: '首页',
        component: index
      },
      /******************************************************************************
       * ****************************************************************************
       * 课程相关
       * ****************************************************************************
       * ****************************************************************************
       ******************************************************************************/
      {
        path: '/watchcourse',
        name: '课程',
        component: () => import('./views/course/watchcourse.vue')
      },
      {
        path: '/watchcourse/:courseId',
        name: '课程详情',
        component: coursebyid,
        props: true
      },
      {
        path: '/watchcourse/:courseId/:lid',
        name: '课程视频',
        component: lesson,
        props: true
      },
      {
        path: '/watchkecb',
        name: '课程组',
        component: watchkecb
      },
      {
        path: '/watchkecb/:id',
        name: '课程组课程',
        component: catebagbyid,
        props: true
      },
      {
        path: '/watchcatebagtype',
        name: '课程组类型',
        component: watchcatebagtype
      },

      {
        path: '/watchpackage',
        name: '代理商课程包',
        component: () => import('./views/packages/watchpackage.vue')
      },
      {
        path: '/watchpackage/:packageId',
        name: '查看课程包',
        component: packageCourse,
        props: true
      },
      {
        path: '/ifreams',
        name: '网页模板',
        component: ifreams,
      },

      {
        path: '/fileurl',
        name: '课程文件',
        component: fileurl,
      },
      {
        path: '/serialgroup',
        name: '序列号组',
        component: Serialgroup
      },
      {
        path: '/serialgroup/course',
        name: '序列号课程',
        component: packageCourse1,
        props: true,
      },
      {
        path: '/serialgroup/password',
        name: '序列号',
        component: packageCourse2,
        props: true,

      },
      /******************************************************************************
       * ****************************************************************************
       * 用户相关
       * ****************************************************************************
       * ****************************************************************************
       ******************************************************************************/
      {
        path: '/user',
        name: '用户',
        component: () => import('./views/user/index.vue')
      },
      {
        path: '/user/addstudent',
        name: '添加学生',
        component: () => import('./views/user/addstudent.vue')
      },
      {
        path: '/user/:userid',
        name: '查看用户',
        component: watchuser,
        props: true,
        redirect: { name: '用户课程' },
        children: [
          {
            path: 'course',
            name: '用户课程',
            component: userCourse,
            props: true
          },
          {
            path: 'teacherfile',
            name: '用户教师课件',
            component: teacherCourse,
            props: true
          },
          {
            path: 'package',
            name: '用户代理商课程包',
            component: userPackage,
            props: true
          },
          {
            path: 'user',
            name: '子用户管理',
            component: userUser,
            props: true
          },
        ]
      },

      /******************************************************************************
      * ****************************************************************************
      * 资源管理
      * ****************************************************************************
      * ****************************************************************************
      ******************************************************************************/
      {
        path: '/oss',
        name: '网盘管理',
        component: oss
      },
      {
        path: '/videos1',
        name: '视频管理',
        component: videos1,
      },
      {
        path: '/secretfile',
        name: '课件管理',
        component: secretfile
      },
      /******************************************************************************
      * ****************************************************************************
      * 教师资料管理
      * ****************************************************************************
      * ****************************************************************************
      ******************************************************************************/
      {
        path: '/teacherdata',
        name: '教师资料组',
        component: teacherdata
      },
      {
        path: '/teacherdata/:ID',
        name: '查看教师资料',
        component: watchteacherproposal,
        props: true
      },
      {
        path: '/itembankgroup',
        name: '题库组',
        component: itembankgroup
      },
      {
        path: '/itembankgroup/:ID',
        name: '题库',
        component: watchitembankgroup,
        props: true
      },
      {
        path: '/itembankanswer',
        name: '完成答题',
        component: answer
      },
      /******************************************************************************
      * ****************************************************************************
      * 微信管理
      * ****************************************************************************
      * ****************************************************************************
      ******************************************************************************/

      {
        path: '/wechat',
        name: 'wechat',
        component: wechat,
        redirect: '/wechat/temp',
        children: [{
          path: '/wechat/temp',
          name: '网页管理',
          component: wechattemp,
        },
        {
          path: '/wechat/pushs',
          name: '推送管理',
          component: wechatpushs,
        },
        {
          path: '/wechat/fans',
          name: '粉丝管理',
          component: wechatfans,
        },
        ]
      },
      /******************************************************************************
      * ****************************************************************************
      * 产品视频管理
      * ****************************************************************************
      * ****************************************************************************
      ******************************************************************************/
      {
        path: '/library',
        name: '图书视频',
        component: library,
      },
      {
        path: '/coderobot',
        name: '机器人视频',
        component: coderobot,
      },
      /******************************************************************************
 * ****************************************************************************
 * 校区管理
 * ****************************************************************************
 * ****************************************************************************
 ******************************************************************************/
      {
        path: '/school',
        name: 'school',
        redirect: '/school/list',
        component: School,
        children: [
          {
            path: '/school/list',
            name: '学校列表',
            component: school_list,
          },
          {
            path: '/school/list/:ID',
            name: '学校内容',
            component: school_watchschool,
            props: true,
          },
          {
            path: '/school/school_groupdetail/:ID',
            component: school_groupdetail,
            props: true,
          },
        ]
      },
    ],
  },
  {
    path: '/login',
    name: '登陆',
    component: login
  },
  {
    //服务器退出 
    path: '/logout',
    name: '退出',
    beforeEnter: function (to, from, next) {
      get("/user/logout")
      next("/login")
      location.href = "/admin.html"
    }
  },
  {
    path: '/newspackage',
    name: 'newspackage',
    component: newspackage
  }
  ]
})